// pages/sign_up_detail/index.js


import { getScheduleJoinDetail } from '../../api/schedule.js'
const app = getApp()
Page({
  /**
   * 页面的初始数据
   */
  data: {
    name: '',//赛事名称
    inputValue:'',//证件号码
    matchId:''//赛事ID
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    wx.setNavigationBarTitle({
      title: options.title
    })
    this.setData({ title: options.title, name: options.name, matchId: options.matchId})
  },
  getInputValue(e){
    this.setData({ inputValue: e.detail.value})
  },
  searchUser(){
    let { inputValue, name, title, matchId}=this.data
    if (!inputValue){
      wx.showToast({
        title: '请输入报名相关证件号码',
        icon:'none'
      })
    }else{
      getScheduleJoinDetail({ matchId: matchId, identity: inputValue}).then(res=>{
        if (res.code == 0 && res.rows.length>0){
          app.globalData.tempData = res.rows
          wx.redirectTo({
            url: '/pages/sign_up_detail/index?title=' + title + '&&name=' + name,
          })
        } else {
          wx.showToast({
            title: '暂无查询到相关数据',
            icon: 'none'
          })
        }
      })
    }
  },
  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})